:root {
  --bg-color: #cbd5e1;
  /* Szary (Slate 300) - nie biały */
  --card-bg: #f1f5f9;
  /* Jasnoszary (Slate 100) - nie biały */
  --card-hover-bg: #e2e8f0;
  /* Slate 200 */
  --text-primary: #0f172a;
  /* Slate 900 */
  --text-secondary: #475569;
  /* Slate 600 */
  --accent-color: #0284c7;
  /* Sky 600 */
  --accent-success: #16a34a;
  /* Green 600 */
  --accent-warn: #ea580c;
  /* Orange 600 */
  --border-color: #94a3b8;
  /* Slate 400 */
  --card-shadow: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.08);
  --transition-speed: 0.3s;

  /* Overlays */
  --item-bg: rgba(0, 0, 0, 0.02);
  --item-border: rgba(0, 0, 0, 0.05);

  /* Ikon Highlights */
  --hl-pressure: #0284c7;
  --hl-flow-temp: #ea580c;
  --hl-flow-total: #16a34a;
  --hl-temp: #dc2626;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow-x: hidden;
}

.app-container {
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex-grow: 1;
}

/* Header Section */
.app-header {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.app-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  background: linear-gradient(to right, #0284c7, #4f46e5);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent-success);
  border-radius: 50%;
  position: relative;
}

.pulse-dot::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--accent-success);
  border-radius: 50%;
  animation: pulse 1.5s infinite ease-in-out;
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }

  100% {
    transform: scale(2.5);
    opacity: 0;
  }
}

/* Flex Layout */
.chambers-grid {
  display: flex;
  flex-flow: row wrap;
  gap: 30px;
  width: 100%;
}

/* Chamber Cards ("Kafelki") */
.chamber-card {
  flex: 0 1 370px;
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--card-shadow);
  transition: transform var(--transition-speed) ease, border-color var(--transition-speed) ease, background-color var(--transition-speed) ease;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chamber-card:hover {
  border-color: var(--accent-color);
  background-color: var(--card-hover-bg);
}

/* Card Header */
.card-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 12px;
}

.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.short-name {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-color);
  background: rgba(56, 189, 248, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.full-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 6px;
  line-height: 1.3;
}

/* Card Metrics Grid */
.metrics-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.metric-item {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  padding: 10px 12px;
  position: relative;
  overflow: hidden;
}

.metric-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.metric-label svg,
.metric-label i {
  font-size: 0.95rem;
  width: 18px;
  text-align: center;
  stroke: var(--text-secondary);
  color: var(--text-secondary);
  flex-shrink: 0;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

.metric-value-wrapper {
  display: flex;
  align-items: baseline;
  gap: 2px;
}

.metric-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.metric-unit {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Highlighted value states */
.metric-item.highlight-cis_tloczenia .metric-label svg,
.metric-item.highlight-cis_tloczenia .metric-label i {
  stroke: #0284c7;
  color: #0284c7;
}

.metric-item.highlight-przeplyw_chwilowy .metric-label svg,
.metric-item.highlight-przeplyw_chwilowy .metric-label i {
  stroke: #ea580c;
  color: #ea580c;
}

.metric-item.highlight-przeplyw_sumaryczny .metric-label svg,
.metric-item.highlight-przeplyw_sumaryczny .metric-label i {
  stroke: #16a34a;
  color: #16a34a;
}

.metric-item.highlight-temperatura .metric-label svg,
.metric-item.highlight-temperatura .metric-label i {
  stroke: #dc2626;
  color: #dc2626;
}

/* Status Styles */
.status-val-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.status-icon svg {
  width: 18px;
  height: 18px;
}

.status-text {
  font-size: 0.9rem;
  font-weight: 700;
}

.status-awaria .status-text {
  color: #ef4444;
  text-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
}

.status-norma .status-text {
  color: #22c55e;
  text-shadow: 0 0 10px rgba(34, 197, 94, 0.2);
}

.status-podwyzszone .status-text {
  color: #f97316;
  text-shadow: 0 0 10px rgba(249, 115, 22, 0.2);
}

.status-unknown .status-text {
  color: var(--text-secondary);
}

/* Loading Spinner */
.loading-spinner-wrapper {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(56, 189, 248, 0.1);
  border-radius: 50%;
  border-top-color: var(--accent-color);
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Footer Section */
.app-footer {
  text-align: center;
  padding: 16px 0;
  font-size: 0.75rem;
  color: var(--text-secondary);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  margin-top: auto;
}

/* Responsive adjust for iframe embedding */
@media (max-width: 600px) {
  body {
    padding: 8px;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .chambers-grid {
    gap: 12px;
  }

  .chamber-card {
    flex-basis: 100%;
  }
}

/* Status Icon FontAwesome styles */
.status-icon i {
  font-size: 1.1rem;
}
.status-awaria .status-icon i {
  color: #ef4444;
}
.status-norma .status-icon i {
  color: #22c55e;
}
.status-podwyzszone .status-icon i {
  color: #f97316;
}
.status-unknown .status-icon i {
  color: var(--text-secondary);
}

/* State badges base style */
.state-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 4.5px;
}

.optimal-badge {
  color: #15803d;
  background: rgba(34, 197, 94, 0.15);
  box-shadow: 0 0 5px rgba(34, 197, 94, 0.1);
  border: 1.5px solid rgba(34, 197, 94, 0.25);
}

.idle-badge {
  color: #475569;
  background: rgba(71, 85, 105, 0.15);
  border: 1.5px solid rgba(71, 85, 105, 0.2);
}

.awaria-badge {
  color: #b91c1c;
  background: rgba(239, 68, 68, 0.15);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.2);
  border: 1.5px solid rgba(239, 68, 68, 0.35);
  animation: badgeBlink 1.5s infinite alternate;
}

.warning-badge {
  color: #c2410c;
  background: rgba(249, 115, 22, 0.15);
  box-shadow: 0 0 5px rgba(249, 115, 22, 0.15);
  border: 1.5px solid rgba(249, 115, 22, 0.35);
}

@keyframes badgeBlink {
  0% {
    opacity: 0.75;
  }
  100% {
    opacity: 1;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.35);
  }
}

/* Chamber Cards States */
.chamber-card.state-optimal {
  border-color: rgba(22, 163, 74, 0.45);
  box-shadow: 0 10px 20px -3px rgba(22, 163, 74, 0.12), 0 4px 6px -4px rgba(22, 163, 74, 0.08);
  background: linear-gradient(135deg, #f1f5f9 0%, #edfcf2 100%);
  animation: cardPulse 3s ease-in-out infinite alternate;
}

.chamber-card.state-optimal:hover {
  border-color: var(--accent-success);
  background: linear-gradient(135deg, #e2e8f0 0%, #dcfce7 100%);
}

.chamber-card.state-awaria {
  border-color: rgba(239, 68, 68, 0.6);
  background: linear-gradient(135deg, #f1f5f9 0%, #fef2f2 100%);
  animation: cardPulseAwaria 2s ease-in-out infinite alternate;
}

.chamber-card.state-awaria:hover {
  border-color: #ef4444;
  background: linear-gradient(135deg, #e2e8f0 0%, #fee2e2 100%);
}

.chamber-card.state-podwyzszone {
  border-color: rgba(249, 115, 22, 0.5);
  background: linear-gradient(135deg, #f1f5f9 0%, #fff7ed 100%);
  animation: cardPulseWarning 2.5s ease-in-out infinite alternate;
}

.chamber-card.state-podwyzszone:hover {
  border-color: #f97316;
  background: linear-gradient(135deg, #e2e8f0 0%, #ffedd5 100%);
}

.chamber-card.state-idle {
  border-color: var(--border-color);
  background: #f1f5f9;
}

.chamber-card.state-idle:hover {
  border-color: var(--text-secondary);
  background: #e2e8f0;
}

/* Metric Items States & Glow Animations */
.animate-pressure-normal {
  animation: pressureGlow 3s ease-in-out infinite alternate;
  border-color: rgba(34, 197, 94, 0.25) !important;
}

.animate-pressure-normal-idle {
  border-color: rgba(34, 197, 94, 0.15) !important;
  background: rgba(34, 197, 94, 0.02) !important;
}

.animate-pressure-awaria {
  animation: pressureGlowAwaria 1.5s ease-in-out infinite alternate;
  border-color: rgba(239, 68, 68, 0.4) !important;
}

.animate-pressure-podwyzszone {
  animation: pressureGlowWarning 2.5s ease-in-out infinite alternate;
  border-color: rgba(249, 115, 22, 0.4) !important;
}

.animate-flow {
  animation: flowGlow 3s ease-in-out infinite alternate;
  border-color: rgba(14, 165, 233, 0.25) !important;
}

.animate-flow .metric-label i {
  color: #0ea5e9 !important;
}

.animate-flow-alert {
  animation: flowGlowAlert 2s ease-in-out infinite alternate;
  border-color: rgba(239, 68, 68, 0.3) !important;
}

.animate-flow-alert .metric-label i {
  color: #ef4444 !important;
}

.animate-temp-hot {
  animation: tempGlowHot 1.5s ease-in-out infinite alternate;
  border-color: rgba(220, 38, 38, 0.4) !important;
}

.animate-temp-hot .metric-label i {
  color: #ef4444 !important;
  animation: firePulse 1.2s ease-in-out infinite alternate;
}

/* Keyframes for custom animations */
@keyframes cardPulse {
  0% {
    box-shadow: 0 10px 20px -3px rgba(22, 163, 74, 0.12), 0 4px 6px -4px rgba(22, 163, 74, 0.08);
  }
  100% {
    box-shadow: 0 10px 20px -3px rgba(22, 163, 74, 0.18), 0 4px 6px -4px rgba(22, 163, 74, 0.12), 0 0 8px 1px rgba(34, 197, 94, 0.15);
  }
}

@keyframes cardPulseAwaria {
  0% {
    box-shadow: 0 10px 20px -3px rgba(239, 68, 68, 0.12), 0 4px 6px -4px rgba(239, 68, 68, 0.08);
  }
  100% {
    box-shadow: 0 10px 20px -3px rgba(239, 68, 68, 0.25), 0 4px 6px -4px rgba(239, 68, 68, 0.15), 0 0 12px 2px rgba(239, 68, 68, 0.25);
  }
}

@keyframes cardPulseWarning {
  0% {
    box-shadow: 0 10px 20px -3px rgba(249, 115, 22, 0.1), 0 4px 6px -4px rgba(249, 115, 22, 0.06);
  }
  100% {
    box-shadow: 0 10px 20px -3px rgba(249, 115, 22, 0.18), 0 4px 6px -4px rgba(249, 115, 22, 0.12), 0 0 10px 1px rgba(249, 115, 22, 0.15);
  }
}

@keyframes pressureGlow {
  0% {
    background: rgba(34, 197, 94, 0.03);
    box-shadow: none;
  }
  100% {
    background: rgba(34, 197, 94, 0.08);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.15);
  }
}

@keyframes pressureGlowAwaria {
  0% {
    background: rgba(239, 68, 68, 0.03);
    box-shadow: none;
  }
  100% {
    background: rgba(239, 68, 68, 0.1);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
  }
}

@keyframes pressureGlowWarning {
  0% {
    background: rgba(249, 115, 22, 0.02);
    box-shadow: none;
  }
  100% {
    background: rgba(249, 115, 22, 0.08);
    box-shadow: 0 0 8px rgba(249, 115, 22, 0.15);
  }
}

@keyframes flowGlow {
  0% {
    background: rgba(14, 165, 233, 0.02);
    box-shadow: none;
  }
  100% {
    background: rgba(14, 165, 233, 0.07);
    box-shadow: 0 0 8px rgba(14, 165, 233, 0.15);
  }
}

@keyframes flowGlowAlert {
  0% {
    background: rgba(239, 68, 68, 0.01);
    box-shadow: none;
  }
  100% {
    background: rgba(239, 68, 68, 0.06);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.15);
  }
}

@keyframes tempGlowHot {
  0% {
    background: rgba(220, 38, 38, 0.01);
    box-shadow: none;
  }
  100% {
    background: rgba(220, 38, 38, 0.08);
    box-shadow: 0 0 8px rgba(220, 38, 38, 0.2);
  }
}

.fa-bounce-water {
  animation: bounceWater 1.6s ease-in-out infinite;
  display: inline-block;
}

@keyframes bounceWater {
  0%, 100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-2.5px) scale(0.9);
  }
}

.fa-spin-slow {
  animation: spin 5s linear infinite;
  display: inline-block;
}

@keyframes firePulse {
  0% {
    transform: scale(1);
    text-shadow: 0 0 2px rgba(239, 68, 68, 0.2);
  }
  100% {
    transform: scale(1.15);
    text-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
  }
}